{extends file="../global.html"}
{block name=body}



 

      
          <div class="content" >
            <!-- 右侧内容框架，更改从这里开始 -->
            <form class="layui-form xbs" action="" >
                <div class="layui-form-pane" style="text-align: center;">
                  <div class="layui-form-item" style="display: inline-block;">
                    <!-- <label class="layui-form-label xbs768">日期范围</label>
                    <div class="layui-input-inline xbs768">
                      <input class="layui-input" placeholder="开始日" id="LAY_demorange_s">
                    </div>
                    <div class="layui-input-inline xbs768">
                      <input class="layui-input" placeholder="截止日" id="LAY_demorange_e">
                    </div> -->
                    <div class="layui-input-inline">
                      <input type="text" name="username"  placeholder="请输入用户名" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline" style="width:80px">
                        <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                    </div>
                  </div>
                </div> 
            </form>
            <xblock><button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon">&#xe640;</i>批量删除</button><button class="layui-btn" onclick="member_add('添加用户','member-add.html','600','500')"><i class="layui-icon">&#xe608;</i>添加</button><span class="x-right" style="line-height:40px">共有数据：88 条</span></xblock>
            <table class="layui-table">
                <thead>
                    <tr>
                     <th>
                          ID
                        </th>
                        <th>
                          轮播地址
                        </th>
                        <th>
                            轮播图片
                        </th>
                        <th>
                            是否显示
                        </th>
                        <th>
                            操作
                        </th>
                    </tr>
                </thead>
                <tbody>
                {foreach $res as $v}
                    <tr class="tr_{$v.carousel_id}">
                        
                        <td class="td"> {$v.carousel_id}</td>
                        <td class="td"> {$v.carousel_url}</td>
                        
                       
                        <td class="td" ><img width="36" src="{$absroot}{$v.carousel_pic}" alt=""></td>
                       
                        <td class="td-status">
                          <span class="layui-btn show-{$v.carousel_id} {if $v.carousel_state == 0} layui-btn-warm {else} layui-btn-normal{/if}   layui-btn-mini  " state="{$v.carousel_state}" onclick="show({$v.carousel_id})"> {if $v.carousel_state == 0}隐藏{else}显示{/if}</span>
                        </td>
                          <td class="td-manage">
                            
                           
                            <a title="编辑" href="{url('/run/carousel/edit/id/'|cat:$v.carousel_id)}" 
                            class="ml-5" style="text-decoration:none">
                                <i class="layui-icon">&#xe642;</i>
                            </a>
                            <a title="删除" href="javascript:;" onclick="del({$v.carousel_id})" 
                            style="text-decoration:none">
                                <i class="layui-icon">&#xe640;</i>
                            </a>
                        </td>
                    </tr>
                   {/foreach}
                </tbody>
            </table>
            <!-- 右侧内容框架，更改从这里结束 -->
            
          </div>
          <script type="text/javascript">

    

function show(id){
  // alert(state);
  var state = $('.show-'+id).attr('state');
  if(state == 1){
    state = 0;
  }else{
    state = 1;
  }
  // alert(state);
  // var navigation_sort = $('.navigation_sort_'+id).val();
   $.ajax({
              type:"post",
              data:{ carousel_id:id,carousel_state:state},
              url:"{url('run/carousel/ajaxState')}",
               success:function(msg){
                // alert(msg);return;
                            if(msg == false){
                              return false;
                            }
                             if(state == 1){
                                   $('.show-'+id).text('显示').removeClass('layui-btn-warm').addClass('layui-btn-normal');
                                     $('.show-'+id).attr('state',1);
                                }else{
                                     $('.show-'+id).text('隐藏').removeClass('layui-btn-normal').addClass('layui-btn-warm'); 
                                      $('.show-'+id).attr('state',0);
                                }
                                  
                          }
            })
}

function del(id){
  $.ajax({
              type:"post",
              data:{ carousel_id:id},
              url:"{url('run/carousel/ajaxDel')}",
               success:function(msg){
                    if(msg == true){
                      layer.msg('删除成功');  
                      $('.tr_'+id).remove();

                    }else{
                       layer.msg('删除失败');  
                    }
               }
})
}
          </script>
        
{/block}
